<?php $index = 0; ?>
<?php $pict_id = $item->image; ?>
<?php $pic = $pict_id->dir.$pict_id->filename; ?>
<?php $price = $item->price; ?>
<?php foreach ($item->promotions->find_all() as $promotion): ?>
	<?php if($promotion->discount_type == 'percent'):?>
		<?php if(($promotion->starting_date < strtotime('now')) && (strtotime('now') < $promotion->ending_date)): ?>
			<?php $price = $price*(1 - ($promotion->discount/100)); ?>
		<?php endif; ?>
	<?php endif; ?>
	<?php if($promotion->discount_type == 'amount'): ?>
		<?php if(($promotion->starting_date < strtotime('now')) && (strtotime('now') < $promotion->ending_date)): ?>
					<?php $price = $price - $promotion->discount;?>
		<?php endif; ?>
	<?php endif; ?>
<?php endforeach; ?>
<div class="center_content">
      <div class="center_title_bar"><?php echo $item->name ?></div>
      <div class="prod_box_big">
        <div class="center_prod_box_big">
          <div class="product_img_big"> <a href="javascript:popImage(<?php echo $pic; ?>,'Some Title')" title="header=[Zoom] body=[&nbsp;] fade=[on]"><?php echo Html::Image('images/'.$item->image->filename, array('width'=>180, 'height'=>140)); ?></a>
          </div>
          <div class="details_big_box">
            <div class="product_title_big"><?php echo $item->name ?></div>
            <div class="specifications"> Availability:
				<?php if($item->in_stock()): ?>
					<span class="blue">In stock</span><br />
				<?php else: ?>
					<span class="blue">Out of stock</span><br />
				<?php endif; ?>
              Description :<span class="blue"><?php echo $item->description; ?></span><br />
            </div>
            <?php $promotions = $item->promotions->find_all()->as_array();?>
			<?php if (empty($promotions)): ?>
				<div class="prod_price_big"><span class="price"><?php echo '$'.$item->price; ?></span>
			<?php else: ?>
				<div class="prod_price_big"><span class="reduce"><?php echo '$'.$item->price; ?></span>
				<span class="price"><?php echo '$'.$price; ?></span>
			<?php endif; ?>
			</div>
            
				<?php if(!$item->discontinued && $item->in_stock()): ?>
					<?php echo Form::open('cart/add/item', array('method'=>'post')) ?>
					<?php echo Form::hidden('item', $item->id); ?>				
						<?php foreach($attributes as $attribute): ?>
							<br><?php echo $attribute->attribute->name.': '; ?>
							<select name="attr<?php echo $attribute->attribute->id; ?>">
								<?php foreach($attribute->values->find_all() as $value): ?>
								<option value="<?php echo $value->id; ?>"><?php echo $value->value; ?></option>
								<?php endforeach; ?>
								<?php $index++; ?>
							</select>
						<?php endforeach;?><br>
					<?php echo Form::submit(NULL, 'Add to Cart'); ?>
					<?php echo Form::close(); ?>
				<?php else: ?>
					<?php echo 'This item is not available.'; ?>
				<?php endif; ?>				
        </div>
      </div>
    </div>
</div>
